﻿using Core.Entities;
using Core.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Api.Commands
{
    /// <summary>
    /// 通过命令名称读取命令信息
    /// </summary>
    public class ReadCommandByName : CommandInfo
    {
        /// <summary>
        /// 通过命令名称读取命令信息
        /// </summary>
        public ReadCommandByName() : base("ReadCommandByName")
        {
            Id = -1;
            Code = "SELECT TOP 1 Id, Name, Type, Code, Sign, CacheToken, Description FROM System_Commands WHERE Name = @Name";
            Sign = CommandSigns.NoCall | CommandSigns.Select;
            Type = "T-SQL";
            Description = "通过命令名称读取命令信息";

            Params = new CommandParamInfo[1];

            CommandParamInfo ParamFlag;

            ParamFlag = Params[0] = new CommandParamInfo();
            ParamFlag.Name = "@Name";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.String;
            ParamFlag.Description = "命令名称";

            Results = new CommandParamInfo[7];

            ParamFlag = Results[0] = new CommandParamInfo();
            ParamFlag.Name = "Id";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.Int;
            ParamFlag.Description = "命令 Id";

            ParamFlag = Results[1] = new CommandParamInfo();
            ParamFlag.Name = "Name";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.String;
            ParamFlag.Description = "命令名称";

            ParamFlag = Results[2] = new CommandParamInfo();
            ParamFlag.Name = "Type";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.String;
            ParamFlag.Description = "命令类型";

            ParamFlag = Results[3] = new CommandParamInfo();
            ParamFlag.Name = "Code";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.String;
            ParamFlag.Description = "命令代码";

            ParamFlag = Results[4] = new CommandParamInfo();
            ParamFlag.Name = "Sign";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.Int;
            ParamFlag.Description = "命令标识";

            ParamFlag = Results[5] = new CommandParamInfo();
            ParamFlag.Name = "CacheToken";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.String;
            ParamFlag.Description = "缓存依据";

            ParamFlag = Results[6] = new CommandParamInfo();
            ParamFlag.Name = "Description";
            ParamFlag.Sign = 0;
            ParamFlag.Type = ParamTypes.String;
            ParamFlag.Description = "命令说明";
        }
    }
}